/*	
*	File: raw-proto.h
*	Date: 2011/11/05
*	User: Ronmaru
*	Desctiption: raw protocol
*/

#ifndef RAW_PROTO_H
#define RAW_PROTO_H

#include <boost/asio/detail/config.hpp>
#include <boost/asio/detail/socket_types.hpp>
#include <boost/asio/basic_raw_socket.hpp>
#include <boost/asio/ip/basic_endpoint.hpp>
#include <boost/asio/ip/basic_resolver.hpp>
#include <boost/asio/ip/basic_resolver_iterator.hpp>
#include <boost/asio/ip/basic_resolver_query.hpp>

#include <boost/asio/detail/push_options.hpp>

using namespace boost;
using namespace asio;
using namespace ip;

/// Encapsulates the flags needed for raw data
class raw
{
public:
  typedef basic_endpoint<raw> endpoint;
  typedef basic_raw_socket<raw> socket;
  typedef basic_resolver<raw> resolver;

  static raw v4()
  {
    return raw(IPPROTO_RAW, PF_INET);
  }
  static raw v6()
  {
    return raw(IPPROTO_RAW, PF_INET);
  }

  int type() const
  {
    return SOCK_RAW;
  }
  int protocol() const
  {
    return protocol_;
  }
  int family() const
  {
    return family_;
  }

  friend bool operator==(const raw& p1, const raw& p2)
  {
    return p1.protocol_ == p2.protocol_ && p1.family_ == p2.family_;
  }

  friend bool operator!=(const raw& p1, const raw& p2)
  {
    return p1.protocol_ != p2.protocol_ || p1.family_ != p2.family_;
  }

private:
  explicit raw(int protocol_id, int protocol_family)
    : protocol_(protocol_id),
      family_(protocol_family)
  { }

  int protocol_;
  int family_;
};

#endif //RAW_PROTO_H